package jrain.fw.script.operator;

import jrain.fw.script.tools.ELException;
import jrain.fw.script.tools.Logger;

//小于等于
public class LessThanOrEqualsOperator extends RelationalOperator {

	public static final LessThanOrEqualsOperator SINGLETON = new LessThanOrEqualsOperator();

	public LessThanOrEqualsOperator() {
	}

	public String getOperatorSymbol() {
		return "<=";
	}

	public Object apply(Object pLeft, Object pRight, Object pContext, Logger pLogger) throws ELException {
		if (pLeft == pRight) {
			return Boolean.TRUE;
		} else if (pLeft == null || pRight == null) {
			return Boolean.FALSE;
		} else {
			return super.apply(pLeft, pRight, pContext, pLogger);
		}
	}

	public boolean apply(double pLeft, double pRight, Logger pLogger) {
		return pLeft <= pRight;
	}

	public boolean apply(long pLeft, long pRight, Logger pLogger) {
		return pLeft <= pRight;
	}

	public boolean apply(String pLeft, String pRight, Logger pLogger) {
		return pLeft.compareTo(pRight) <= 0;
	}

}
